classicube_sys\vectors\vec/
ops.rs

1use core::ops::{Add, Div, Mul, Neg, Sub};
2
3use crate::{bindings::*, std_types::c_float};
4
5impl Add<Self> for Vec3 {
6    type Output = Self;
7
8    fn add(mut self, other: Self) -> Self {
9        self.x += other.x;
10        self.y += other.y;
11        self.z += other.z;
12        self
13    }
14}
15
16impl Add<c_float> for Vec3 {
17    type Output = Self;
18
19    fn add(mut self, other: c_float) -> Self {
20        self.x += other;
21        self.y += other;
22        self.z += other;
23        self
24    }
25}
26
27impl Sub<Self> for Vec3 {
28    type Output = Self;
29
30    fn sub(mut self, other: Self) -> Self {
31        self.x -= other.x;
32        self.y -= other.y;
33        self.z -= other.z;
34        self
35    }
36}
37
38impl Sub<c_float> for Vec3 {
39    type Output = Self;
40
41    fn sub(mut self, other: c_float) -> Self {
42        self.x -= other;
43        self.y -= other;
44        self.z -= other;
45        self
46    }
47}
48
49impl Mul<Self> for Vec3 {
50    type Output = Self;
51
52    fn mul(mut self, other: Self) -> Self {
53        self.x *= other.x;
54        self.y *= other.y;
55        self.z *= other.z;
56        self
57    }
58}
59
60impl Mul<c_float> for Vec3 {
61    type Output = Self;
62
63    fn mul(mut self, other: c_float) -> Self {
64        self.x *= other;
65        self.y *= other;
66        self.z *= other;
67        self
68    }
69}
70
71impl Div<Self> for Vec3 {
72    type Output = Self;
73
74    fn div(mut self, other: Self) -> Self {
75        self.x /= other.x;
76        self.y /= other.y;
77        self.z /= other.z;
78        self
79    }
80}
81
82impl Div<c_float> for Vec3 {
83    type Output = Self;
84
85    fn div(mut self, other: c_float) -> Self {
86        self.x /= other;
87        self.y /= other;
88        self.z /= other;
89        self
90    }
91}
92
93impl Neg for Vec3 {
94    type Output = Self;
95
96    fn neg(mut self) -> Self {
97        self.x = -self.x;
98        self.y = -self.y;
99        self.z = -self.z;
100        self
101    }
102}